package com.example.demo.config;

import com.example.demo.interceptor.CommonInterceptor;
import com.example.demo.interceptor.DataSourceInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * fileName:InterceptorConfiguration
 * description: 将自定义拦截器加到Spring容器中。
 * author: LJV
 * createTime:2022/4/2 15:28
 * version:1.0.0
 */
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    @Autowired
    private CommonInterceptor commonInterceptor;
    @Autowired
    private DataSourceInterceptor dataSourceInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(commonInterceptor);
        registry.addInterceptor(dataSourceInterceptor);
    }

}
